package com.cssl.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import com.cssl.vo.Lv;

@Controller
public class RestController {
	
	@GetMapping("/user/*/createUser??")
	public String ant() {
		System.out.println("ant...");
		int i = 10/0;
		return "ok";
	}
	
	@GetMapping("/user/**/createUser")
	public String ant2(Lv lv) {
		System.out.println("ant2:"+lv);
		return "ok";
	}

	/**
	 * rest风格：以资源为导向
	 */
	@GetMapping("/company/{companyId}/**/{cname}/detail")
	public String rest(@PathVariable int companyId,
					   @PathVariable String cname,Lv lv) {
		System.out.println("rest:"+companyId+"\t"+cname);
		System.out.println("rest:"+lv);
		return "ok";
	}
	
	/**
	 * 局部异常处理
	 * @param e
	 * @return
	 */
	@ExceptionHandler(Exception.class)
	public String error(Exception e) {
		System.out.println("报错了:"+e.getMessage());
		return "demo";
	}
}
